package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.ExamMapper;
import com.tanhua.dubbo.mappers.OptionsMapper;
import com.tanhua.model.domain.Options;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class OptionsApiImpl implements OptionsApi{
    @Autowired
    private OptionsMapper optionsMapper;

    @Override
    public List<Options> findByQuestionsId(Integer questionsId) {
        LambdaQueryWrapper<Options> lqw = new LambdaQueryWrapper<>();
        lqw.eq(questionsId!=null,Options::getQuestionsId,questionsId);
        return optionsMapper.selectList(lqw);
    }

    @Override
    public String findQuestionIdById(String optionId) {
        LambdaQueryWrapper<Options> lqw = new LambdaQueryWrapper<>();
        lqw.eq(optionId!=null,Options::getId,optionId);
        return optionsMapper.selectOne(lqw).getQuestionsId();
    }
}
